#include "board.h"
#include "MotorControl.h"


HBridge_TypeDef hstHBdg_1 = {
    // ===== Hw =====
//    TIM_Channel_1,
    PORT_HB_PWM1A,
    PORT_HB_PWM1B,
    PIN_HB_PWM1A,
    PIN_HB_PWM1B,
    
    // ===== Param =====
    HB_Dir_Forward,
    DEFAULT_HB_DIRMODE,
    DEFAULT_RESERVED,
    DEFAULT_RESERVED,
    DEFAULT_HB_STATE,
    DEFAULT_RESERVED,

    // ===== Private Param =====
    true
};

HBridge_TypeDef hstHBdg_2 = {
    // ===== Hw =====
    PORT_HB_PWM2A,
    PORT_HB_PWM2B,
    PIN_HB_PWM2A,
    PIN_HB_PWM2B,
    
    // ===== Param =====
    HB_Dir_Forward,
    DEFAULT_HB_DIRMODE,
    DEFAULT_RESERVED,
    DEFAULT_RESERVED,
    DEFAULT_HB_STATE,
    DEFAULT_RESERVED,

    // ===== Private Param =====
    true
};

HBridge_TypeDef hstHBdg_3 = {
    // ===== Hw =====
    PORT_HB_PWM3A,
    PORT_HB_PWM3B,
    PIN_HB_PWM3A,
    PIN_HB_PWM3B,
    
    // ===== Param =====
    HB_Dir_Forward,
    DEFAULT_HB_DIRMODE,
    DEFAULT_RESERVED,
    DEFAULT_RESERVED,
    DEFAULT_HB_STATE,
    DEFAULT_RESERVED,

    // ===== Private Param =====
    true
};

HBridge_TypeDef hstHBdg_4 = {
    // ===== Hw =====
    PORT_HB_PWM4A,
    PORT_HB_PWM4B,
    PIN_HB_PWM4A,
    PIN_HB_PWM4B,
    
    // ===== Param =====
    HB_Dir_Forward,
    DEFAULT_HB_DIRMODE,
    DEFAULT_RESERVED,
    DEFAULT_RESERVED,
    DEFAULT_HB_STATE,
    DEFAULT_RESERVED,

    // ===== Private Param =====
    true
};

Enc_TypeDef hstEnc_1 = {
    // ===== Hw =====
    TIM_ENC1,
    
    // ===== Param =====
    DEFAULT_ENC_DIRMODE,
    DEFAULT_ENC_PULS_PER_REV,
    
    // ===== Private Param ====
    0,      // u32Loops
    0,      // u16CntZeroPos
    true    // ParamChanged
};

Enc_TypeDef hstEnc_2 = {
    // ===== Hw =====
    TIM_ENC2,
    
    // ===== Param =====
    DEFAULT_ENC_DIRMODE,
    DEFAULT_ENC_PULS_PER_REV,
    
    // ===== Private Param ====
    0,      // u32Loops
    0,      // u16CntZeroPos
    true    // ParamChanged
};

Enc_TypeDef hstEnc_3 = {
    // ===== Hw =====
    TIM_ENC3,
    
    // ===== Param =====
    DEFAULT_ENC_DIRMODE,
    DEFAULT_ENC_PULS_PER_REV,
    
    // ===== Private Param ====
    0,      // u32Loops
    0,      // u16CntZeroPos
    true    // ParamChanged
};

Enc_TypeDef hstEnc_4 = {
    // ===== Hw =====
    TIM_ENC4,
    
    // ===== Param =====
    DEFAULT_ENC_DIRMODE,
    DEFAULT_ENC_PULS_PER_REV,
    
    // ===== Private Param ====
    0,      // u32Loops
    0,      // u16CntZeroPos
    true    // ParamChanged
};

Motor_TypeDef M1 = {
    // ===== RO Param =====
    0,  // s32D3SpeedFdbk
    0,  // s32d3PositonFdbk
     
    // ===== RW Param =====
    0,  // s32D3SpeedTar
    0,  // s32d3PositionTar
    1,  // s16ReductionRatio
    DEFAULT_MOT_CTRL_MOD,  // u16MotCtrlMod
    
    // ===== Private Param ====
    true,        // ParamChanged
//    0,           // s32d3PosOld
    0,           // s32d3PwmDuty
    
    // ===== Resources =====
    0,              // stPosSpd.s32d3LoopsOld
    0,              // stPosSpd.s32d3LoopsCur
    &hstHBdg_1,     // pstHBdg
    &hstEnc_1,      // pstEnc
    0               // stPidSpd, stPidPos
};

Motor_TypeDef M2 = {
    // ===== RO Param =====
    0,  // s32D3SpeedFdbk
    0,  // s32d3PositonFdbk
     
    // ===== RW Param =====
    0,  // s32D3SpeedTar
    0,  // s32d3PositionTar
    1,  // s16ReductionRatio
    DEFAULT_MOT_CTRL_MOD,  // u16MotCtrlMod
    
    // ===== Private Param ====
    true,        // ParamChanged
//    0,           // s32d3PosOld
    0,           // s32d3PwmDuty
    
    // ===== Resources =====
    0,              // stPosSpd.s32d3LoopsOld
    0,              // stPosSpd.s32d3LoopsCur
    &hstHBdg_2,     // pstHBdg
    &hstEnc_2,      // pstEnc
    0               // stPidSpd, stPidPos
};

Motor_TypeDef M3 = {
    // ===== RO Param =====
    0,  // s32D3SpeedFdbk
    0,  // s32d3PositonFdbk
     
    // ===== RW Param =====
    0,  // s32D3SpeedTar
    0,  // s32d3PositionTar
    1,  // s16ReductionRatio
    DEFAULT_MOT_CTRL_MOD,  // u16MotCtrlMod
    
    // ===== Private Param ====
    true,        // ParamChanged
//    0,           // s32d3PosOld
    0,           // s32d3PwmDuty
    
    // ===== Resources =====
    0,              // stPosSpd.s32d3LoopsOld
    0,              // stPosSpd.s32d3LoopsCur
    &hstHBdg_3,     // pstHBdg
    &hstEnc_3,      // pstEnc
    0               // stPidSpd, stPidPos
};

Motor_TypeDef M4 = {
    // ===== RO Param =====
    0,  // s32D3SpeedFdbk
    0,  // s32d3PositonFdbk
     
    // ===== RW Param =====
    0,  // s32D3SpeedTar
    0,  // s32d3PositionTar
    1,  // s16ReductionRatio
    DEFAULT_MOT_CTRL_MOD,  // u16MotCtrlMod
    
    // ===== Private Param ====
    true,        // ParamChanged
//    0,           // s32d3PosOld
    0,           // s32d3PwmDuty
    
    // ===== Resources =====
    0,              // stPosSpd.s32d3LoopsOld
    0,              // stPosSpd.s32d3LoopsCur
    &hstHBdg_4,     // pstHBdg
    &hstEnc_4,      // pstEnc
    0               // stPidSpd, stPidPos
};
